Untangle reshape imports --> Define pivot_table in DataFrame #17215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative to #17174. This is ultimately a better solution to the issue there, but involves a more invasive refactoring.
To recap:
Right now
DataFrame.pivot_tableis defined incore.reshape.pivotwithDataFrame.pivot_table = pivot_table. The original and main goal of this (and move pivot_table doc-string to DataFrame #17174) is to avoid that, and instead defineDataFrame.pivot_tablewithin theDataFrameclass definition.Doing this makes the docstrings tricky, since we want
pivot_table.__doc__to be shared byreshape.pivot.pivot_tableandDataFrame.pivot_table. To resolve this cleanly, we need to importreshape.pivotat the top ofcore.frame. Doing this requires getting the import ofDataFrameout ofreshape.pivot(and anything else it imports, namelyreshape.concat).Bonus: If/when this is approved, all of the mid-module imports of
reshape.concatcan be moved to the top ofcore.frame, and a handful of other docstrings can be put into_shared_docsin more convenient locations.Bonus 2: If/when this is approved, doing the same thing in
reshape.mergeandreshape.tileis very easy.reshape.reshapeis doable but take a bit more work.git diff upstream/master -u -- "*.py" | flake8 --diff